/**
 * sysServiceFeeServiceImpl
 * 项目名称:分秒金融
 *
 * @author lunli
 *
 * 功能描述:服务费设置管理
 * 
 * 历史版本:2017-03-27 v1.0.0 lunli  创建:
 * 
 */
package com.fmjr.sys.sysServiceFee.service.impl;

import com.fmjr.common.base.exception.BusinessException;
import com.fmjr.common.base.util.Pager;
import com.fmjr.common.util.SqlUtil;
import com.fmjr.sys.sysServiceFee.bean.SysServiceFee;
import com.fmjr.sys.sysServiceFee.dao.SysServiceFeeDao;
import com.fmjr.sys.sysServiceFee.service.ISysServiceFeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;


@Service("sysServiceFeeService")
public class  SysServiceFeeServiceImpl implements ISysServiceFeeService {
	

	@Autowired
    private SysServiceFeeDao sysServiceFeeDao;

	/**
	 * 根据条件查询服务费设置记录
	 * @author lunli
	 * @param  pager
	 * @return SysServiceFeeList
	 * @throws BusinessException
	 */
	public void selectSysServiceFeeList(Pager<SysServiceFee> pager) throws BusinessException{
		int totalCount = sysServiceFeeDao.selectSysServiceFeeCount(pager);
		int numPerPage = SqlUtil.checkPageSize(pager.getNumPerPage());
		int currentPage = SqlUtil.checkPageCurrent(totalCount, numPerPage, pager.getPageNum());
		pager.setLimitStart(SqlUtil.countOffset(currentPage, numPerPage));
		pager.setPageSize(numPerPage);
		pager.setCurrentPage(currentPage);
		pager.setTotalCount(totalCount);
		pager.setTotalPage(totalCount%numPerPage==0?totalCount/numPerPage:totalCount/numPerPage+1);
		List<SysServiceFee> list = sysServiceFeeDao.selectSysServiceFeeList(pager);
		pager.setList(list);
	}
	
	/**
	 * 根据ID查询服务费设置记录
	 * @author lunli
	 * @param id
	 * @return domain
	 * @throws BusinessException
	 */
	public SysServiceFee selectSysServiceFee() throws BusinessException{
		return sysServiceFeeDao.selectSysServiceFee();
	}

	/**
	 *  删除服务费设置记录
	 * @author lunli	 
	 * @param id
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int deleteSysServiceFeeById(Long id) throws BusinessException{
		return sysServiceFeeDao.deleteSysServiceFeeById(id);
	}
	
	/**
	 * 修改服务费设置记录
	 * @author lunli
	 * @param sysServiceFee
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int updateSysServiceFee(SysServiceFee sysServiceFee) throws BusinessException{
		sysServiceFee.setUpdateDate(new Date());
		return sysServiceFeeDao.updateSysServiceFeeSelective(sysServiceFee);
	}

	/**
	 * 新增服务费设置记录
	 * @author lunli
	 * @param sysServiceFee
	 * @return
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int createSysServiceFee(SysServiceFee sysServiceFee) throws BusinessException{
		sysServiceFee.setCreateDate(new Date());
		return sysServiceFeeDao.createSysServiceFee(sysServiceFee);
	}

	@Override
	public List<SysServiceFee> selectSysServiceFeeAll() {
		return sysServiceFeeDao.selectSysServiceFeeAll();
	}
	

	

}
